<script setup name="Subcontracting">
import Form from './form.vue'
import { listDept } from '@/api/system/dept'

import {
  GetListAPI,
  GetPlanListAPI,
  DelDataAPI,
  AddDataAPI,
  EditDataAPI,
  DetailDataAPI,
  SubmitReviewAPI,
  DeleteReviewAPI,
  ClosePlanAPI,
  GetPlanDetailAPI,
  PlanReleaseAPI,
  PlanConfirmationAPI,
  BackPlanAPI,
  ToExamineAPI
} from '@/api/order/purchase/plan'
import { reactive } from 'vue'
const deptOptions = ref([])
const { proxy } = getCurrentInstance()
// 封装 方法 字典查询
const {
  procurement_plan_status // 单据状态
} = proxy.useDict('procurement_plan_status')

const FormRef = ref(null)
const Ids = ref([])
const BtnLoading = ref(false)
// 新增单据弹窗
const addIsShow = ref(false)

// 关结
const closingShow = ref(false)

// id
const closingId = ref(null)

// 单据审核弹窗
const examineIsShow = ref(false)

// 查看
const dxamineIsShow = ref(false)

// 计划下达回显弹窗
const planReleaseIsShow = ref(false)

// 计划下达数据
const planReleaseTable = ref(false)

// 弹窗title
const title = ref('新增')

// 是否禁用删除
const DelDisabled = ref(false)

// 是否禁用 单选
const ExamineDisabled = ref(false)

// 是否禁用 单选
const BomexamineDisabled = ref(false)
// 上列表加载
const Toploading = ref(false)

// 上列表
const TopTableData = ref([])

// 上列表选中数据
const TopSelection = ref([])

// 上列表总数量
const total = ref(0)

// 上列表查询
const query = reactive({
  pageNum: 1,
  pageSize: 50,
  purchaseNum: '',
  materialName: '',
  supplierName: '',
  supplierName: ''
})

// 列表加载
const bomLoading = ref(false)

// 列表
const bomTableData = ref([])

// 列表选中数据
const bomSelection = ref([])

// 列表总数量
const bomTotal = ref(0)

const rows = ref([{ id: '' }])
// 列表查询
const bomQuery = reactive({
  pageNum: 1,
  pageSize: 10
})

const ruleForm = ref({})

const ruleFormRef = ref(null)
// 下达表单
const releaseForm = reactive({
  lowerWeightTotal: '', // 下达总数量
  demandTime: '', // 需求时间
  plannedUnitPrice: '', // 计划单价

  planList: [
    {
      planId: '', // 采购计划id
      lowerWeight: '' // 下达数量
    }
  ]
})

// 计划下达总数量 校验
const validator = (rule, value, callback) => {
  let num = 0
  releaseForm.planList.forEach(item => (num = num + Number(item.lowerWeight)))
  if (value < num) return callback(new Error('下达总数量应大于等于分数量之和'))
  callback()
}

// 计划下达校验
const rules = reactive({
  lowerWeightTotal: [
    { required: true, message: '请填写总数量', trigger: 'blur' },
    { validator: validator, trigger: 'blur' }
  ],
  demandTime: [{ required: true, message: '请选择需求时间', trigger: 'change' }],
  plannedUnitPrice: [{ required: true, message: '请填写计划单价', trigger: 'blur' }],
  taxIncludedPrice: [{ required: true, message: '请填写含税单价', trigger: 'blur' }]
})

// 查询条件
const SelectList = ref([
  { type: '日期范围' },
  { label: '采购计划单号', model: 'purchasementNum', type: '输入框' },
  { label: '销售订单号', model: 'salesOrderNum', type: '输入框' },
  {
    label: '单据状态',
    model: 'status',
    type: '下拉单选',
    opt: procurement_plan_status
  },
  {
    label: '需求部门',
    model: 'demandDept',
    type: '树结构下拉',
    config: { value: 'deptId', label: 'deptName', children: 'children' },
    opt: deptOptions
  },
  { label: '物料编码', model: 'materialCode', type: '输入框' },
  { label: '规格型号', model: 'specType', type: '输入框' }
])

/**
 * 弹窗 SAT-------------------------------
 */

//  新增
const add = () => {
  title.value = '新增'
  addIsShow.value = true
}

// 修改
const edit = async id => {
  title.value = '修改'
  proxy.$modal.loading('请稍后')
  try {
    const res = await DetailDataAPI(id)
    ruleForm.value = res.data
    addIsShow.value = true
  } catch {
  } finally {
    proxy.$modal.closeLoading()
  }
}

// 单据审核 弹窗打开
const examine = async () => {
  const Obj = rows.value[0]
  if (Obj.status != 6 && Obj.status != 7) return proxy.warningMsg('此操作仅为待待审核和审核中状态可用')
  title.value = '审核单据'
  const res = await DetailDataAPI(Ids.value[0])
  if (res.code !== 200) return
  ruleForm.value = res.data
  examineIsShow.value = true
}

// 计划下达
const planRelease = async () => {
  const isif = rows.value.every(item => item.status == 1 || item.status == 8)
  if (!isif) return proxy.warningMsg('此操作仅为待下达和下达中状态可用')
  // const Obj = rows.value[0]
  // const ifis = rows.value.every(
  //   item => item.materialCode == Obj.materialCode && item.qualityStandard == Obj.qualityStandard
  // )
  // if (!ifis) return proxy.warningMsg('您所选择的物料编码和质量标准不一致')
  proxy.$modal.loading('请稍候...')
  try {
    const res = await GetPlanDetailAPI(Ids.value.join(','))
    releaseForm.planList = res.data
    planReleaseIsShow.value = true
  } catch {
  } finally {
    proxy.$modal.closeLoading()
  }
}

/**
 * 弹窗 END-------------------------------
 */

// 新增数据提交
const addSub = async () => {
  try {
    const Obj = await FormRef.value.submit()
    if (!Obj) return
    BtnLoading.value = true
    await AddDataAPI(Obj)
    close()
    getTopList()
    proxy.successMsg('添加成功')
  } catch {
  } finally {
    BtnLoading.value = false
  }
}

// 修改数据提交
const editSub = async () => {
  const Obj = await FormRef.value.submit()
  if (!Obj) return
  try {
    BtnLoading.value = true
    await EditDataAPI(Obj)
    close()
    getTopList()
    proxy.successMsg('修改成功')
  } catch {
  } finally {
    BtnLoading.value = false
  }
}

// 删除
const del = async val => {
  const MesBox = await proxy.DelMessageBox()
  if (!MesBox) return
  const res = await DelDataAPI(Ids.value.length <= 0 ? val : Ids.value.join(','))
  if (res.code !== 200) return (BtnLoading.value = false)
  getTopList()
  proxy.successMsg('删除成功')
}

// 查看
const Dxamine = async val => {
  try {
    proxy.$modal.loading('请稍候...')
    title.value = '查看'
    rows.value = [val]
    const res = await DetailDataAPI(val.id)
    ruleForm.value = res.data
    examineIsShow.value = true
  } catch {
  } finally {
    proxy.$modal.closeLoading()
  }
}

// 提交审核
const subExamine = async () => {
  const isif = rows.value.every(item => item.status == 5)
  if (!isif) return proxy.warningMsg('此操作仅为待提交状态可用！')
  const MesBox = await proxy.FreezMessageBox('是否确定提交审核？')
  if (!MesBox) return
  const res = await SubmitReviewAPI({ idStr: Ids.value.join(',') })
  if (res.code !== 200) return (BtnLoading.value = false)
  proxy.successMsg('操作成功')
  getTopList()
}

/**
 * 批量审核
 */
const allExamine = async () => {
  const is = rows.value.every(t => ['6', '7'].includes(t.status))
  if (!is) return proxy.warningMsg('只有待审核和审核中的数据可操作!')
  const num = rows.value.length
  const MesBox = await proxy.FreezMessageBox1(`共${num}条审核订单`)
  if (MesBox) {
    await ToExamineAPI({
      idStr: Ids.value.join(','),
      isAdopt: '1'
    })
    getTopList()
  } else {
    await ToExamineAPI({
      idStr: Ids.value.join(','),
      isAdopt: '2'
    })
    getTopList()
  }
}

// 撤销审核
const revoke = async () => {
  const Obj = rows.value[0]
  if (Obj.status != 6) return proxy.warningMsg('此操作仅为待审核状态可用')
  const MesBox = await proxy.FreezMessageBox('是否确定撤销审核？')
  if (!MesBox) return
  const res = await DeleteReviewAPI(Ids.value[0])
  if (res.code !== 200) return (BtnLoading.value = false)
  proxy.successMsg('操作成功')

  getTopList()
}

// 审核同意 || 不同意  （同意1 不同意 2
const yesAndNo = async val => {
  const isif = await FormRef.value.submit()
  if (!isif) return
  try {
    BtnLoading.value = true
    const form = {
      reviewComments: isif.reviewComments,
      idStr: Ids.value.join(','),
      isAdopt: val
    }
    await ToExamineAPI(form)
    examineIsShow.value = false
    getTopList()
    proxy.successMsg('操作成功')
  } catch {
  } finally {
    BtnLoading.value = false
  }
}

// 关结单据
const closing = async val => {
  // console.log(rows.value[0].status)
  if (rows.value[0].status == 4) return proxy.warningMsg('此数据已关结')
  const Obj = {
    id: Ids.value[0],
    closeReason: val.closeReason
  }
  const res = await ClosePlanAPI(Obj)
  if (res.code !== 200) return
  proxy.successMsg('操作成功')
  getTopList()
  closingShow.value = false
}

// 计划下达提交
const planReleaseSub = async () => {
  ruleFormRef.value.validate(async (valid, fields) => {
    if (!valid) return proxy.warningMsg('请填写完整')
    try {
      const ifis = releaseForm.planList.every(item => item.lowerWeight)
      if (!ifis) return proxy.warningMsg('请填写下达量!')
      BtnLoading.value = true
      releaseForm.planList.forEach(item => (item.planId = item.id))
      await PlanReleaseAPI(releaseForm)
      proxy.successMsg('操作成功')
      close()
      getTopList()
    } catch {
      BtnLoading.value = false
    } finally {
      BtnLoading.value = false
    }
  })
}

// 计划确认
// const planConfirm = async () => {
//   const Obj = rows.value[0]
//   if (Obj.status != 1) return proxy.warningMsg(' 此操作仅为预下单状态可用')
//   const MesBox = await proxy.FreezMessageBox('是否确定计划？')
//   if (!MesBox) return
//   const res = await PlanConfirmationAPI({ detailId: bomSelection.value[0] })
//   if (res.code !== 200) return
//   proxy.successMsg('操作成功')

//   getTopList()
// }

// 撤回
const backPlan = async () => {
  const Obj = rows.value[0]
  if (Obj.status != 1) return proxy.warningMsg(' 此操作仅为预下单状态可用 ')
  const MesBox = await proxy.FreezMessageBox('是否撤回？')
  if (!MesBox) return
  const res = await BackPlanAPI(bomSelection.value[0])
  if (res.code !== 200) return
  proxy.successMsg('操作成功')

  getTopList()
}

// 弹窗关闭
const close = () => {
  addIsShow.value = false
  examineIsShow.value = false
  dxamineIsShow.value = false
  planReleaseIsShow.value = false
  BtnLoading.value = false
  ruleForm.value = {
    materialCategory: '1', // 物料类别
    demandDept: '', // 需求部门
    remark: '', // 备注
    enclosureUrl: '', // 附件
    materialList: []
  }

  Object.keys(releaseForm).forEach(item => (releaseForm[item] = ''))
}

/**
 * 不能输入小数点
 * @param e
 * @param row
 */
const handleChangePackCount = (e, row) => {
  e = e.replace(/[^0-9]/g, '')
  row.plannedUnitPrice = e
}

// 上列表 选中
const TophandleSelectionChange = row => {
  if (row.length > 0) closingId.value = row[0].id
  TopSelection.value = row
  rows.value = row
  Ids.value = row.map(item => item.id)
  DelDisabled.value = !row.length
  row.length <= 0 || row.length > 1 ? (ExamineDisabled.value = true) : (ExamineDisabled.value = false)
}
TophandleSelectionChange([])

// 下列表 选中
const bomHandleSelectionChange = row => {
  // bomSelection.value = row
  rows.value = row
  bomSelection.value = row.map(item => item.id)
  row.length <= 0 || row.length > 1 ? (BomexamineDisabled.value = true) : (BomexamineDisabled.value = false)
}
bomHandleSelectionChange([])
// 查询条件
const selectSubmit = val => {
  for (let key in val) {
    query[key] = val[key]
  }
  getTopList()
}
function handleAdd(row) {
  listDept().then(response => {
    deptOptions.value = proxy.handleTree(response.data, 'deptId')
  })

  if (row != undefined) {
    ruleForm.demandDept = row.deptId
  }
}
handleAdd()
// 获取上列表
const getTopList = async () => {
  Toploading.value = true
  try {
    const res = await GetListAPI(query)
    if (res.code !== 200) return
    total.value = res.total
    TopTableData.value = res.rows
    getBomList()
  } catch (error) {
  } finally {
    Toploading.value = false
  }
}

// 获取下列表
const getBomList = async () => {
  bomLoading.value = true
  try {
    const res = await GetPlanListAPI(query)
    bomTotal.value = res.total
    bomTableData.value = res.rows
  } catch (error) {
  } finally {
    bomLoading.value = false
  }
}
getTopList()

// 计算下达总数量
const comput = () => {
  let total = 0
  releaseForm.planList.forEach(item => {
    total = Number(item.lowerWeight) + total
    releaseForm.lowerWeightTotal = total
  })
}

const tableHeight = ref(0)

const maxHeight = computed(() => {
  const windowHeight = window.innerHeight
  const headerHeight = 310
  const paginationHeight = 0
  return windowHeight - headerHeight - paginationHeight
})

const handleResize = () => {
  tableHeight.value = maxHeight.value
}

onMounted(() => {
  tableHeight.value = maxHeight.value
  window.addEventListener('resize', handleResize)
})

onBeforeUnmount(() => {
  window.removeEventListener('resize', handleResize)
})
</script>

<template>
  <div class="app-container">
    <!-- 查询条件组件 -->
    <SelectForm :SelectForm="SelectList" @selectSubmit="selectSubmit" />
    <el-card class="box-card">
      <!-- 按钮 -->
      <el-button type="primary" v-hasPermi="['order:purchase:plan:add']" @click="add">添加单据</el-button>
      <el-button
        type="warning"
        v-hasPermi="['order:purchase:plan:subExamine']"
        :disabled="DelDisabled"
        @click="subExamine"
        >提交审核</el-button
      >
      <el-button type="warning" v-hasPermi="['order:purchase:plan:review']" :disabled="DelDisabled" @click="allExamine"
        >批量审核</el-button
      >
      <el-button type="primary" v-hasPermi="['order:purchase:plan:revoke']" :disabled="DelDisabled" @click="revoke"
        >撤销审核</el-button
      >
      <el-button type="primary" v-hasPermi="['order:purchase:plan:review']" :disabled="ExamineDisabled" @click="examine"
        >审核</el-button
      >
      <el-button
        type="primary"
        v-hasPermi="['order:purchase:plan:closing']"
        :disabled="ExamineDisabled"
        @click="closingShow = true"
        >关结单据</el-button
      >
      <el-button
        type="primary"
        v-hasPermi="['order:purchase:plan:planRelease']"
        :disabled="DelDisabled"
        @click="planRelease"
        >计划下达</el-button
      >
      <el-button
        type="primary"
        v-hasPermi="['order:purchase:plan:backPlan']"
        :disabled="BomexamineDisabled"
        @click="backPlan"
        >撤回</el-button
      >
      <!-- <el-button
        type="primary"
        v-hasPermi="['order:purchase:plan:planConfirm']"
        :disabled="BomexamineDisabled"
        @click="planConfirm"
        >计划确认</el-button
      > -->
      <el-button type="danger" v-hasPermi="['order:purchase:plan:remove']" :disabled="DelDisabled" @click="del"
        >删除</el-button
      >
      <!-- <el-button type="info" @click="importFn">导入</el-button> -->
      <!-- <el-button type="info" @click="exportFn">导出</el-button> -->
      <!-- 列表 -->
      <div class="table">
        <div class="top">
          <!-- 上列表 -->
          <el-table
            v-loading="Toploading"
            stripe
            border
            :data="TopTableData"
            class="tableClass"
            @selection-change="TophandleSelectionChange"
            :height="maxHeight"
          >
            <el-table-column type="selection" width="55" align="center" fixed="left" />
            <el-table-column label="序号" width="70" type="index" />
            <el-table-column label="采购需求单号" prop="purchaseNum" width="220" />
            <el-table-column label="单据状态" width="120">
              <template #default="scope">
                <p-dictTag :options="procurement_plan_status" :value="scope.row.status" />
              </template>
            </el-table-column>
            <el-table-column label="物料名称" prop="materialName" width="200" />
            <el-table-column label="物料编码" prop="materialCode" width="180" />
            <el-table-column label="规格型号" prop="specType" width="120" />
            <el-table-column label="计划数量" prop="planWeight" width="120" />
            <el-table-column label="单位" prop="unitDict" width="auto" />
            <el-table-column label="需求时间" prop="demandTime" width="220" />
            <el-table-column label="需求人" prop="demander" width="120" />
            <el-table-column label="需求部门" prop="demandDeptDict" width="120" />
            <el-table-column label="开单时间" prop="createTime" width="220" />
            <el-table-column label="审核人" prop="reviewBy" width="120" />
            <el-table-column label="审核时间" prop="reviewTime" width="220" />
            <el-table-column
              label="操作"
              align="center"
              width="160"
              fixed="right"
              class-name="small-padding fixed-width"
            >
              <template #default="scope">
                <div>
                  <el-link
                    v-hasPermi="['order:purchase:plan:edit']"
                    type="primary"
                    v-show="scope.row.status == 2 || scope.row.status == 5"
                    text="修改"
                    @click="edit(scope.row.id)"
                  />
                  <el-link
                    v-hasPermi="['order:purchase:plan:remove']"
                    v-show="scope.row.status == 2 || scope.row.status == 5"
                    type="primary"
                    text="删除"
                    @click="del(scope.row.id)"
                  />
                  <el-link
                    type="primary"
                    text="查看"
                    v-hasPermi="['order:purchase:plan:query']"
                    @click="Dxamine(scope.row)"
                  />
                </div>
              </template>
            </el-table-column>
          </el-table>
          <pagination
            :fixed="false"
            v-show="total > 0"
            :total="total"
            v-model:page="query.pageNum"
            v-model:limit="query.pageSize"
            @pagination="getTopList"
          />
        </div>
        <!-- <div class="buttom">
          <div class="title">单据信息</div>
          <el-table
            height="230"
            v-loading="bomLoading"
            stripe
            border
            :data="bomTableData"
            style="margin-top: 10px"
            @selection-change="bomHandleSelectionChange"
          >
            <el-table-column type="selection" width="55" align="center" fixed="left" />
            <el-table-column label="序号" width="70" type="index" />
            <el-table-column label="采购计划单号" prop="purchasementNum" width="220" />
            <el-table-column label="单据状态" width="120">
              <template #default="scope">
                <p-tag bgc="#23cdb7" text="预下单" v-if="scope.row.status == 1" />
                <p-tag bgc="#36a0da" text="待到货" v-else-if="scope.row.status == 2" />
                <p-tag bgc="#36a0da" text="部分到货" v-else-if="scope.row.status == 3" />
                <p-tag bgc="#bebebe" text="已完成" v-else-if="scope.row.status == 4" />
                <p-tag bgc="#9a9a9a" text="已关结" v-else-if="scope.row.status == 5" />
                <p-tag bgc="#8e7cc3" text="待下单" v-else />
              </template>
            </el-table-column>
            <el-table-column label="物料名称" prop="materialName" width="200" />
            <el-table-column label="物料编码" prop="materialCode" width="200" />
            <el-table-column label="规格型号" prop="specType" width="200" />
            <el-table-column label="单位" prop="unitDict" width="auto" />
            <el-table-column label="计划单价(元)" prop="plannedUnitPrice" width="220" />
            <el-table-column label="下达数量" prop="lowerWeight" width="auto" />
            <el-table-column label="含税单价(元)" prop="taxIncludedPrice" width="220" />
            <el-table-column label="需求时间" prop="demandTime" width="220" />
          </el-table>
          <pagination
            :fixed="false"
            v-show="bomTotal > 0"
            :total="bomTotal"
            v-model:page="bomQuery.pageNum"
            v-model:limit="bomQuery.pageSize"
            @pagination="getBomList"
          />
        </div> -->
      </div>
    </el-card>
    <!-- 新增弹窗 -->
    <p-XiaoheDialog :dialogVisible="addIsShow" :title="title" @close="close" width="70%">
      <template #body>
        <Form
          ref="FormRef"
          :data="ruleForm"
          :title="title"
          :db="title == '单据审核' || title == '查看'"
          :examine="title == '单据审核'"
        />

        <!-- 按钮 -->
        <div class="flex-between btn" v-if="title == '新增' || title == '修改'">
          <div></div>
          <div>
            <el-button :loading="BtnLoading" type="primary" @click="title == '新增' ? addSub() : editSub()"
              >保存</el-button
            >
            <el-button @click="close">取消</el-button>
          </div>
        </div>
      </template>
    </p-XiaoheDialog>
    <!-- 审核弹窗 -->
    <p-XiaoheDialog :dialogVisible="examineIsShow" :title="title" @close="close" width="50%">
      <template #body>
        <div>
          <AuditHistory
            :title="title == '查看' ? '基本信息' : '审核'"
            :auditDoc="rows[0].purchaseNum"
            perms="order:purchase:plan:review"
          >
            <template #body>
              <Form ref="FormRef" :data="ruleForm" db :title="title" :examine="title == '审核单据'" />
              <div class="Btn" v-if="title == '审核单据'">
                <el-button type="danger" :loading="BtnLoading" @click="yesAndNo(2)">不同意</el-button>
                <el-button type="success" :loading="BtnLoading" @click="yesAndNo(1)">同意</el-button>
                <el-button type="inof" @click="close">取消</el-button>
              </div>
            </template>
          </AuditHistory>
        </div>
      </template>
    </p-XiaoheDialog>
    <!-- 计划下达 -->
    <p-XiaoheDialog :dialogVisible="planReleaseIsShow" title="计划下达" @close="close" width="75rem">
      <template #body>
        <el-table stripe border :data="releaseForm.planList" style="margin: 10px 0">
          <!-- <el-table-column type="selection" width="55" align="center" fixed="left" /> -->
          <el-table-column label="序号" width="70" type="index" />
          <el-table-column label="采购需求单号" prop="purchaseNum" show-overflow-tooltip width="120" />
          <el-table-column label="物料名称" prop="materialName" show-overflow-tooltip width="auto" />
          <el-table-column label="物料编码" prop="materialCode" show-overflow-tooltip width="auto" />
          <el-table-column label="规格型号" prop="specType" show-overflow-tooltip width="auto" />
          <el-table-column label="单位" prop="unitDict" show-overflow-tooltip width="auto" />
          <el-table-column label="计划量" prop="planWeight" show-overflow-tooltip width="auto" />
          <el-table-column label="下达量" show-overflow-tooltip width="180">
            <template #default="scope">
              <el-input
                type="number"
                oninput="if(value<=0)value=''"
                v-model="scope.row.lowerWeight"
                @change="comput"
              ></el-input>
            </template>
          </el-table-column>
          <!-- <el-table-column label="计划单价(元)" show-overflow-tooltip width="180">
            <template #default="scope">
              <el-input
                type="number"
                @input="e => handleChangePackCount(e, scope.row)"
                oninput="if(value<=0)value=''"
                clearable
                v-model="scope.row.plannedUnitPrice"
              ></el-input>
            </template>
          </el-table-column> -->

          <el-table-column label="需求时间" width="220">
            <template #default="scope">
              <el-date-picker
                v-model="scope.row.demandTime"
                type="datetime"
                format="YYYY/MM/DD hh:mm:ss"
                value-format="YYYY-MM-DD hh:mm:ss"
                placeholder="请选择需求时间"
              />
            </template>
          </el-table-column>
          <!-- <el-table-column label="单位" prop="unitDict" width="80" /> -->
        </el-table>
        <el-form
          ref="ruleFormRef"
          inline
          scroll-to-error
          :model="releaseForm"
          :rules="rules"
          label-width="auto"
          label-position="right"
          status-icon
        >
          <!-- <el-form-item label="计划单价(元)" prop="plannedUnitPrice">
            <el-input
              type="number"
              oninput="if(value<=0)value=''"
              clearable
              v-model="releaseForm.plannedUnitPrice"
            ></el-input>
          </el-form-item> -->

          <!-- <el-form-item label="含税单价(元)" prop="taxIncludedPrice">
            <el-input
              type="number"
              oninput="if(value<=0)value=''"
              clearable
              v-model="releaseForm.taxIncludedPrice"
            ></el-input>
          </el-form-item> -->
          <!-- <el-form-item label="下达总数量" prop="lowerWeightTotal">
            <el-input
              type="number"
              oninput="if(value<=0)value=''"
              clearable
              v-model="releaseForm.lowerWeightTotal"
            ></el-input>
          </el-form-item> -->
          <!-- <el-form-item label="需求时间" prop="demandTime">
            <el-date-picker
              v-model="releaseForm.demandTime"
              type="datetime"
              format="YYYY/MM/DD hh:mm:ss"
              value-format="YYYY-MM-DD hh:mm:ss"
              placeholder="请选择时间"
            />
          </el-form-item> -->
        </el-form>
        <!-- 按钮 -->
        <div class="flex-between btn">
          <div></div>
          <div>
            <el-button :loading="BtnLoading" type="primary" @click="planReleaseSub">下达</el-button>
            <el-button @click="close">取消</el-button>
          </div>
        </div>
      </template>
    </p-XiaoheDialog>
    <!-- 关结 -->
    <Closing v-if="closingShow" :id="closingId" :isShow="closingShow" @submit="closing" @close="closingShow = false" />
  </div>
</template>

<style lang="scss" scoped>
.table {
  .top {
    height: 50%;
    overflow: auto;
  }
  .buttom {
    height: 50%;
    overflow: auto;
  }
}
.a {
  margin-top: 20px;
}
</style>
